#ifndef MAIN_XFONT_H_
#define MAIN_XFONT_H_

typedef struct {
	const char *path;
    bool opened;
	bool isInit;
    int font_size;// 字符大小
    int bin_type;
    int total_font_cnt; // 字符总数
    int font_page;  // 显示一个字符的二进制数据，需要的长度
    int font_unicode_cnt;
    int unicode_begin_idx;
    char* strAllUnicodes;
    char* fontFilePath;
	FILE *file;
	unsigned long time_spent;
    int screenWidth;
    TFT_t *tft;
} XFont;

void InitXFont(XFont* xfont, const char* fontPath) ;
int getFontPage(int font_size, int bin_type) ;
char* getStringFromChars(uint8_t* bs, int l) ;
char* getUnicodeFromUTF8(XFont* xfont,const char* s) ;
char* getPixBinStrFromString(XFont* xfont, const char* strUnicode) ;
//char* getPixDataFromHex(const char* s) ;
void DrawSingleStr(XFont* xfont, int x, int y, const char* strBinData, int fontColor, int backColor, bool ansiChar) ;

//void DrawChineseEx(XFont* xfont,int x, int y, const char*  str, int fontColor);
void DrawChineseEx(XFont* xfont,int x, int y, const char*  str, int fontColor,int backColor);
char*  getCodeDataFromFile(XFont* xfont,const char* strUnicode);
char* getPixDataFromHex(XFont* xfont, const char* s, char* out_result);
void DrawStrEx(XFont* xfont,int x, int y, const char*  str, int fontColor,int backColor);

// UTF8 to SJIS table
// https://www.mgo-tec.com/blog-entry-utf8sjis01.html
//#define Utf8Sjis "Utf8Sjis.tbl"
//uint16_t UTF2SJIS(spiffs_file fd, uint8_t *utf8);
//int String2SJIS(spiffs_file fd, unsigned char *str_in, size_t stlen, uint16_t *sjis, size_t ssize);
#endif /* MAIN_XFont_H_ */

